function deepClone(obj, cache = new WeakMap()) {
    if (obj === null || typeof obj !== 'object') return obj
    if (obj instanceof Date) return new Date(obj)
    if (obj instanceof RegExp) return new RegExp(obj)

    if (cache.has(obj)) return cache.get(obj)
    let cloneObj = new obj.constructor()
    cache.set(obj, cloneObj)

    for (let key in obj) {
        if (obj.hasOwnProperty(key)) {
            cloneObj[key] = deepClone(obj[key], cache)
        }
    }
    return cloneObj
}
const obj = {
    name: 'Jack',
    address: { x: 100, y: 200 },
    arr: [{ address1: { x: 100, y: 200 } },
        { address2: { x: 100, y: 200 } }]
}
obj.a = obj // 循环引用
const newObj = deepClone(obj)
console.log('obj.a.a :>> ', obj)
console.log('newObj.a.a :>> ', newObj)
console.log(newObj.a === obj.a) // false